<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<br/>

<form:form action="resultupdate.pt" method="POST">
	<input type="hidden" name="action_value" id="idActionValue" value="" />
	
	<form:errors path="*" cssClass="error-message"/>
	
	<table class="input-table">
	<tbody>
		<tr>
			<td>Course</td>
			<td>
				<form:select path="course" onchange="doSubmit('action_course_select')" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${courses}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
			<td>Semester</td>
			<td>
				<form:select path="subCourse" onchange="doSubmit('action_semester_select')" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${semesters}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
			<td></td>
		</tr>
		<tr>
			<td>Exam Type</td>
			<td>
				<form:select path="examType" onchange="doSubmit('action_examtype_select')" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${examTypes}"/>
				</form:select>
			</td>
			<td>Exam</td>
			<td>
				<form:select path="exam" cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${exams}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
			<td width="40%">
				<input type="button" value="Show" name="action_btn_show" onclick="doSubmit('action_show')"/>
			</td>
		</tr>
		<tr>
			<td colspan="6">
				<table width="100%">
					<tbody>
						<tr>
							<th colspan="4">Exam Deatils:</th>
						<tr>
						<tr>
							<td>Exam ID</td><td><c:out value="${command.exam.examId}"/></td>
							<td>Exam Date</td><td><fmt:formatDate value="${command.exam.examDate}" pattern="dd-MM-yyyy"/></td>
							<td>Subject</td><td><c:out value="${command.exam.subject.name}"/></td>
							<td>Total Mark</td><td><c:out value="${command.exam.totalMark}"/></td>
							<td>Pass Mark</td><td><c:out value="${command.exam.passMark}"/></td>
						<tr>
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>

<table class="list-results-table">
	<tbody>
		<tr>
			<th>Student Name</th>
			<th>Student Reg. No.</th>
			<th>Mark Obtained</th>
			<th>Remarks</th>
			<th width="15%">Last Updated Date</th>
		</tr>
		
		<c:forEach items="${command.examResults}" var="result" varStatus="intx">
		<tr>
			<td><c:out value="${result.student.name}"/></tD>
			<td><c:out value="${result.student.registrationNo}"/></tD>
			<td><form:input path="examResults[${intx.count - 1}].obtainedMark" /></tD>
			<td><form:textarea path="examResults[${intx.count - 1}].remarks" cssStyle="width:15em;" rows="1"/> </tD>
			<td>
				<fmt:formatDate value="${department.lastUpdatedDate}" pattern="dd-MM-yyyy"/>
			</td>
		</tr>
		</c:forEach>
	</tbody>
</table>

<c:if test="${examResultsount > 0}">
<div class="bottom-btn">
	<input type="button" value="Save" name="action_btn_save" onclick="doSubmit('action_save')" <c:out value="${disableBtn} "/> />
</div>
</c:if>
</form:form>